package org.example.classtopia.Mapper;

import org.apache.ibatis.annotations.*;
import java.util.List;
import java.time.LocalDateTime;
import org.example.classtopia.Model.Entity.AiChatSession;
import org.example.classtopia.Model.Entity.AiChatMessage;

@Mapper
public interface AiChatMapper {
        // 会话相关
        int insert(AiChatSession session);

        AiChatSession selectById(@Param("id") String id);

        List<AiChatSession> selectAll(@Param("offset") int offset, @Param("limit") int limit);

        long countAll();

        int update(AiChatSession session);

        int deleteById(@Param("id") String id);

        List<AiChatSession> selectSessions(@Param("userId") Long userId, @Param("offset") int offset,
                        @Param("limit") int limit);

        // 消息相关
        int insertMessage(AiChatMessage message);

        List<AiChatMessage> selectMessagesBySessionId(@Param("sessionId") String sessionId, @Param("offset") int offset,
                        @Param("limit") int limit);

        int deleteMessagesBySessionId(@Param("sessionId") String sessionId);

        void updateLastActivity(@Param("sessionId") String sessionId, @Param("updatedAt") LocalDateTime updatedAt);
}
